Public Class frmSHIFTCHANGE
    
    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub frmSHIFTCHANGE_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Try
            GC.Collect()
            Me.Dispose()
        Catch ex As Exception

        End Try
    End Sub


    Private Sub frmRECALL_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        PublicFunction.NewFormLoad(Me)

        Me.GridDetail.RootTable.Columns("QUANTITY").FormatString = PublicVariable.NumberFormatString
        Me.GridDetail.RootTable.Columns("PRICE").FormatString = PublicVariable.NumberFormatString

        Me.GridDetail.RootTable.Columns("TOTAL_ORG").FormatString = PublicVariable.NumberFormatString
        Me.GridDetail.RootTable.Columns("TOTAL_ORG").TotalFormatString = PublicVariable.NumberFormatString

        Me.GridDetail.RootTable.Columns("VAT_AMT").FormatString = PublicVariable.NumberFormatString
        Me.GridDetail.RootTable.Columns("VAT_AMT").TotalFormatString = PublicVariable.NumberFormatString

        Me.GridDetail.RootTable.Columns("DSC_AMT").FormatString = PublicVariable.NumberFormatString
        Me.GridDetail.RootTable.Columns("DSC_AMT").TotalFormatString = PublicVariable.NumberFormatString

        Me.GridDetail.RootTable.Columns("LINE_TOTAL").FormatString = PublicVariable.NumberFormatString
        Me.GridDetail.RootTable.Columns("LINE_TOTAL").TotalFormatString = PublicVariable.NumberFormatString
        txtFromDate.Text = PublicVariable.SystemDate.ToString(PublicVariable.DateTimeFormat)
        Dim arName As New ArrayList
        arName.Add("@USER_CODE")
        arName.Add("@BILL_DATE")

        Dim arVal As New ArrayList
        arVal.Add(PublicVariable.UserCode)
        arVal.Add(PublicVariable.SystemDate)
        GridDetail.DataSource = BLL.ObjectGetBy("RPT_BYUSER", arName, arVal)
    End Sub

    Private Sub btnShiftEnd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShiftEnd.Click
        If SystemFunction.ShowYesNoForm("DO YOU WANT TO END SHIFT", "") = Windows.Forms.DialogResult.Yes Then
            Dim dt As DataTable
            Dim arName As New ArrayList
            arName.Add("@USER_CODE")
            arName.Add("@BILL_DATE")
            Dim arVal As New ArrayList
            arVal.Add(PublicVariable.UserCode)
            arVal.Add(PublicVariable.SystemDate)
            dt = BLL.ObjectGetBy("RPT_CLOSESHIFT", arName, arVal)

            Me.Close()
            Application.Exit()
        End If
    End Sub

    Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click

        Dim DirPath As String
        DirPath = "C:\"
        Dim DateNow As DateTime = PublicVariable.SystemDate

        SaveFileDialog1.Filter = "Excel files (*.xls)|*.xls"
        SaveFileDialog1.InitialDirectory = DirPath
        SaveFileDialog1.FileName = "Shift_End" + DateNow.ToString("_ddMMyyyy") + ".xls"
        If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Dim ReportFile As String = SaveFileDialog1.FileName
            Dim stream As New IO.FileStream(ReportFile, IO.FileMode.Create)
            Try
                GridEXExporter1.GridEX = Me.GridDetail
                GridEXExporter1.Export(stream)
                stream.Flush()
                SystemFunction.ShowMessageForm("EXPORT COMPLETED!", "")
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
            Finally
                stream.Dispose()
            End Try

        End If
    End Sub
End Class